import com.niit.dao.*;
import com.niit.dao.impl.*;
import com.niit.domain.*;
import org.junit.jupiter.api.Test;
import sun.util.resources.LocaleData;

import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;
import java.util.Locale;

public class test01 {

    @Test
    public void CarouselTest(){
        ICarouselDao iCarouselDao = new CarouselDaoImpl();
        List<Carousel> list = iCarouselDao.queryCarousel(2);
        for (Carousel carousel: list) {
            System.out.println(carousel);
        }

    }
    @Test
    public void NoticeTest(){
        INoticeDao iNoticeDao=new NoticeDaoImpl();
        Notice notice=iNoticeDao.queryNotice();
        System.out.println(notice);

    }
    @Test
    public void ProductTest(){
        IProductDao iProductDao=new ProductDaoImpl();
        List<Product> list=iProductDao.queryProduct(5);
        for(Product product:list){
            System.out.println(product);
        }
    }


    @Test
    public void ProductTest1(){
        IProductDao iProductDao=new ProductDaoImpl();
        List<Product> list=iProductDao.queryByIs_good(8);
        for(Product product:list){
            System.out.println(product);
        }
    }

    @Test
    public void NewsTest1(){
        INewsDao iNewsDao=new NewsDaoImpl();
        List<News> list=iNewsDao.queryNews(5);
        for(News news:list){
            System.out.println(news);
        }
    }

    @Test
    public void NewsTest2(){
        INewsDao iNewsDao1=new NewsDaoImpl();
        List<News> list=iNewsDao1.queryNews2(5);
        for(News news:list){
            System.out.println(news);
        }
    }

    @Test
    public void Leave_message(){
        ILeave_messageDao iLeave_messageDao = new Leave_messageDaoImpl();
        Leave_message leave_message = new Leave_message();
        leave_message.setLname("Jack");
        leave_message.setContent("得价钱");
        leave_message.setPhone("110");
        ZoneId zoneId = ZoneId.systemDefault();
        LocalDate localDate = LocalDate.now();
        ZonedDateTime zdt = localDate.atStartOfDay(zoneId);

        Date date = Date.from(zdt.toInstant());
        System.out.println(date);
      leave_message.setLtime(date);
        int i = iLeave_messageDao.insertMessageDao(leave_message);


    }


    @Test
    public void NewsTest3(){
        INewsDao iNewsDao2=new NewsDaoImpl();
        List<News> list=iNewsDao2.queryNews3(5);
        for(News news:list){
            System.out.println(news);
        }
    }

    @Test
    public void ClassTest(){
        IClassificationDao iClassificationDao=new ClassificationDaoImpl();
        List<Classification> list=iClassificationDao.queryClassification();
        for(Classification classification:list){
            System.out.println(classification);
        }
    }

    @Test
    public void ProductTest9(){
        IProductDao iProductDao = new ProductDaoImpl();
        List<Product> list = iProductDao.queryProducts(1,4);
        for (Product product:list){
            System.out.println(product);
        }
    }

    @Test
    public void ProductTest10(){
        IProductDao iProductDao = new ProductDaoImpl();
        int i = iProductDao.queryTotal();
        System.out.println(i);
    }

    @Test
    public void NewsTest7(){
        INewsDao iNewsDao = new NewsDaoImpl();
        List<News> list = iNewsDao.queryAllNews(0,4);
        for(News news:list){
            System.out.println(news);
        }
        System.out.println("+++++++++"+iNewsDao.queryNewsTotal());
    }
    @Test
    public void productByIdTest(){
        IProductDao iProductDao = new ProductDaoImpl();
        Product product =iProductDao.queryProductByID(1);
        System.out.println(product);
    }


    @Test
    public void newsNum_click(){
        INewsDao iNewsDao = new NewsDaoImpl();
        int i = iNewsDao.NewsCountadd(1);
    }


    @Test
    public void productNum(){
        IProductDao iProductDao = new ProductDaoImpl();
        iProductDao.productsCountadd(1);

    }
}
